package com.adingxiong.security.springsecurity.entity;

import org.springframework.stereotype.Component;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * @ClassName ImageCode
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/10/16 16:01
 **/
public class ImageCode {

    private BufferedImage bufferedImage;

    private String code;

    private LocalDateTime localDateTime;

    public ImageCode(String code ,BufferedImage bufferedImage,LocalDateTime localDateTime){
        this.bufferedImage = bufferedImage;
        this.code = code;
        this.localDateTime = localDateTime;
    }

    public ImageCode(BufferedImage bufferedImage,String code ,int time ){
        this.bufferedImage = bufferedImage;
        this.code = code;
        this.localDateTime = LocalDateTime.now().plusSeconds(time);
    }

    public boolean isExpire(){
        return  LocalDateTime.now().isAfter(localDateTime);
    }

    public BufferedImage getBufferedImage() {
        return bufferedImage;
    }

    public void setBufferedImage(BufferedImage bufferedImage) {
        this.bufferedImage = bufferedImage;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getLocalDateTime() {
        return localDateTime;
    }

    public void setLocalDateTime(LocalDateTime localDateTime) {
        this.localDateTime = localDateTime;
    }
}
